package com.bainuo.doctor.common.base;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bainuo.doctor.common.R;

/**
 * 空数据显示
 */
public class EmptyDataFragment extends BaseFragment {

    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    private String mEmptyText = "没有查找到相应的数据";
    private String mParam2;

//    @BindView(R.id.tv_content)
    TextView mTvContent;


    public EmptyDataFragment() {
    }

    /**
     * 获取实例
     */
    public static EmptyDataFragment newInstance(String param1, String param2) {
        EmptyDataFragment fragment = new EmptyDataFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mEmptyText = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }


    @Override
    public View onCreateFragmentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_empty_data, container, false);
        mTvContent = (TextView) view.findViewById(R.id.tv_content);
        return view;
    }

    @Override
    public void initView() {

        mTvContent.setText(mEmptyText);
        mTvContent.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mListener != null) {
                    mListener.onClickListener(v);
                }
            }
        });
    }



    /**
     * callback
     */
    private OnClickListener mListener;


    /**
     * 监听事件
     */
    public void setListener(OnClickListener listener) {
        mListener = listener;
    }

    /**
     * 点击回调
     */
    public interface OnClickListener {
        /**
         * callback
         *
         * @param view view
         */
        void onClickListener(View view);
    }

}
